package model

import (
	"qabx.net/safe-app-center/pkg/utils"
	"time"
)

type TblDeviceScanThreat struct {
	ScanId        string `json:"scan_id"`
	DeviceId      int    `json:"device_id"`
	ThreatType    string `json:"threat_type"`
	ThreatName    string `json:"threat_name"`
	ThreatDesc    string `json:"threat_desc"`
	ScanTime      string `json:"scan_time"`
	Port          int    `json:"port"`
	Protocol      string `json:"protocol"`
	ServiceName   string `json:"service_name"`
	VulnType      string `json:"vuln_type"`
	VulnName      string `json:"vuln_name"`
	VulnServerity string `json:"vuln_servertiry"`
	VulnDesc      string `json:"vuln_desc"`
	VulnSolution  string `json:"vuln_solution"`
	VulnCnnvd     string `json:"vuln_cnnvd"`
	VulnCve       string `json:"vuln_cve"`
	VulnCpe       string `json:"vuln_cpe"`
	BreachKey     string `json:"breach_key"`
	CreateTime    string `json:"create_time"`
	UpdateTime    string `json:"update_time"`
	IsDel         int    `json:"is_del"`
}

func (s *TblDeviceScanThreat) AddDeviceScanThreat() error {
	dbClient, _ := utils.GetDbClient()
	s.CreateTime = time.Now().Format("2006-01-02 15:04:05")
	s.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
	s.IsDel = 0

	dbClient.InsertParam = utils.InsertParam{
		Resource: s,
		Table:    "tbl_device_scan_threat",
	}
	_, err := dbClient.Insert()
	if err != nil {
		return err
	}
	return err

}
